package analytics;

import java.rmi.Remote;
import java.rmi.RemoteException;

import event.Event;

import management.ClientEventReceiver;

/**
 * Offers the possibility of subscribing or unsubscribing for event notifications to the management clients.
 * 
 * @author Lukas
 *
 */
public interface AnalyticsServer extends Remote {
	/**
	 * Subscribe for event notifications.
	 * @param filter A regular expression describing witch events should be passed to the callback object.
	 * @param receiver The callback object where the notifications should be sent to.
	 * @return A unique subscription identifier.
	 * @throws RemoteException
	 */
	public String subscribe(String filter, ClientEventReceiver receiver) throws RemoteException;
	/**
	 * Unsubscribe from event notifications.
	 * @param id The subscription identifier that was returned by the subscribe-method.
	 * @return <tt>true</tt> if the unsubscription was successful, otherwise <tt>false</tt>.
	 * @throws RemoteException
	 */
	public boolean unsubscribe(String id) throws RemoteException;
	/**
	 * Receives an event notification and forwards them to the subscribed clients.
	 * @param event The event that happened.
	 * @throws RemoteException
	 */
	public void processEvent(Event event) throws RemoteException;
}
